class JsonCache {
	cache = {};

	isserver = true;

	async loadCache(name: string): Promise<any> {
		if (!name) {
			return null;
		}
		if (this.cache[name]) {
			return this.cache[name];
		}
		const file = this.getFull(name);
		const json = this.isserver ? await server.LoadJsonByUrl(file) : await loadJsonByUrl(file);
		if (json) {
			this.setCache(name, json);
			return json;
		}
		return null;
	}

	clearCache(name: string): void {
		delete this.cache[name];
	}

	setCache(name: string, json: any): void {
		this.cache[name] = json;
	}

	getFull(name: string): string {
		return '';
	}

	saveFile(file: string, s: string): void {
		const f = this.getFull(file);
		const full = (this.isserver ? server.getAssets() : getAssets()) + f;
		FsUtils.saveFile(full, s);
	}
}
